home *** CD-ROM | disk | FTP | other *** search
/ C & C++ Multimedia Cyber Classroom / C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso / cpphtp2 / code.jar / code / ch11 / fig11_26.txt < prev    next >
Text File  |  1998-02-27  |  780b  |  23 lines

  1. 1   // Fig. 11.26: fig11_26.cpp 
  2. 2   // Displaying floating-point values in system default,
  3. 3   // scientific, and fixed formats.
  4. 4   #include <iostream.h>
  5. 5   
  6. 6   int main()
  7. 7   {
  8. 8      double x = .001234567, y = 1.946e9;
  9. 9   
  10. 10     cout << "Displayed in default format:\n"
  11. 11          << x << '\ ' << y << '\n';
  12. 12     cout.setf( ios::scientific, ios::floatfield );
  13. 13     cout << "Displayed in scientific format:\n"
  14. 14          << x << '\ ' << y << '\n';
  15. 15     cout.unsetf( ios::scientific );
  16. 16     cout << "Displayed in default format after unsetf:\n" 
  17. 17          << x << '\ ' << y << '\n';
  18. 18     cout.setf( ios::fixed, ios::floatfield );
  19. 19     cout << "Displayed in fixed format:\n"
  20. 20          << x << '\ ' << y << endl;
  21. 21     return 0;
  22. 22  }
  23.